package com.davidhigenbottam.HeatMap.client;


import com.google.gwt.event.logical.shared.OpenEvent;
import com.google.gwt.event.logical.shared.OpenHandler;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.Widget;

public class Disclosures {

//	public static Label DATA_SOURCE_HTML = new Label("Change Data Source ("+DataSources.DEFAULT.getName()+")");
//	public static Label QUERY_HTML = new Label("Define Query");
//	public static Label OVERLAYS_HTML = new Label("Manage Overlays");
//	public static Label KML_HTML = new Label("KML files");
	
	public final static DisclosurePanel DATA_SOURCE = new DisclosurePanel("Data Source");
	public final static DisclosurePanel QUERY = new DisclosurePanel("Query");
	public final static DisclosurePanel OVERLAYS = new DisclosurePanel("Overlays");
	public final static DisclosurePanel KML = new DisclosurePanel("Downloads");
	
	public final static DisclosurePanel[] disclosurePanels= {DATA_SOURCE,QUERY,OVERLAYS,KML};
	

	
	public Disclosures(){
//		DATA_SOURCE.setHeader(DATA_SOURCE_HTML);
//		QUERY.setHeader(QUERY_HTML);
//		OVERLAYS.setHeader(OVERLAYS_HTML);
//		KML.setHeader(KML_HTML);
		
		
		
		for(final DisclosurePanel dp: disclosurePanels){
			dp.setAnimationEnabled(true);
			
			dp.addOpenHandler(new OpenHandler<DisclosurePanel>(){
				@Override
				public void onOpen(OpenEvent<DisclosurePanel> event) {
					closeAllBut(dp);
				}});
			
			
		}
		
		//DATA_SOURCE.setWidth("250px");
		//QUERY.setWidth("320px");
		//OVERLAYS.setWidth("200px");
		//KML.setWidth("100px");

		
	}
	
	public void closeAllBut(DisclosurePanel thisOne){
		for(DisclosurePanel dp: disclosurePanels){
			if(dp==thisOne)
				dp.setOpen(true);
			else
				dp.setOpen(false);
		}
	}
	
	public void open(DisclosurePanel dp){
		closeAllBut(dp);
	}
	public void close(DisclosurePanel dp){
		dp.setOpen(false);
	}
	
	public void setContent(DisclosurePanel dp, Widget w){
		dp.setContent(w);
	}
	
	
}
